package br.com.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.biblioteca.Book;
import br.com.biblioteca.BookList;

@WebServlet("/Edit.do")
public class BookEditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public BookEditServlet() {
        super();
       
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		PrintWriter out = response.getWriter();
		
		String key = request.getParameter("logica");
		
		BookList lista = BookList.getSingleton();	
		
		Book livro = lista.getBook(key);
		
		request.setAttribute("codigo", key);
		request.setAttribute("titulo", livro.getTitle());
		
		RequestDispatcher view = request.getRequestDispatcher("Editor.jsp");
		
		view.forward(request,response);
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
